$(document).ready(function() {
    $.getJSON("/file/getFiles", function (data) {
        htmlStr = "<thead><tr class=&quot;text-c&quot;><th width=&quot;50&quot;>编号</th>" +
            "<th width=&quot;150&quot;>文件名称</th>" +
            "<th width=&quot;50&quot;>上传日期</th>" +
            "<th width=&quot;50&quot;>操作</th></tr></thead>";
        $.each(data, function (infoindex, info) {
            var create_time = new Date(info["upload_time"]).toLocaleDateString();
            htmlStr += "<tbody><tr class=&quot;text-c&quot;>";
            htmlStr += "<td>" + info["file_id"]+ "</td>";
            htmlStr += "<td>" + info["file_name"] + "</td>";
            htmlStr += "<td>" + create_time + "</td>";
            htmlStr += "<td><a id='download' href="+"/file/download/" + info["file_id"] + ">下载</a></td>";
            htmlStr += "</tr></tbody>"
        })
        $("#table").html(htmlStr);
    });

    $("#find").click(function () {
        var file_name = $("#file_name").val();
        if (file_name == "") {
            $.getJSON("/file/getFiles", function (data) {
                htmlStr = "<thead><tr class=&quot;text-c&quot;><th width=&quot;50&quot;>编号</th>" +
                    "<th width=&quot;150&quot;>文件名称</th>" +
                    "<th width=&quot;50&quot;>上传日期</th>" +
                    "<th width=&quot;50&quot;>操作</th></tr></thead>";
                $.each(data, function (infoindex, info) {
                    var create_time = new Date(info["upload_time"]).toLocaleDateString();
                    htmlStr += "<tbody><tr class=&quot;text-c&quot;>";
                    htmlStr += "<td>" + info["file_id"]+ "</td>";
                    htmlStr += "<td>" + info["file_name"] + "</td>";
                    htmlStr += "<td>" + create_time + "</td>";
                    htmlStr += "<td><a id='download' href="+"/file/download/" + info["file_id"] + ">下载</a></td>";
                    htmlStr += "</tr></tbody>"
                })
                $("#table").html(htmlStr);
            });
        }
        else {
            var url = "/file/queryByKeyWord" + "?file_name=" + file_name;
            $.getJSON(url, function (data) {
                $("#table").empty();
                htmlStr = "<thead><tr class=&quot;text-c&quot;><th width=&quot;50&quot;>编号</th>" +
                    "<th width=&quot;150&quot;>文件名称</th>" +
                    "<th width=&quot;50&quot;>上传日期</th>" +
                    "<th width=&quot;50&quot;>操作</th></tr></thead>";
                $.each(data, function (infoindex, info) {
                    var create_time = new Date(info["upload_time"]).toLocaleDateString();
                    htmlStr += "<tbody><tr class=&quot;text-c&quot;>";
                    htmlStr += "<td>" + info["file_id"]+ "</td>";
                    htmlStr += "<td>" + info["file_name"] + "</td>";
                    htmlStr += "<td>" + create_time + "</td>";
                    htmlStr += "<td><a id='download' href="+"/file/download/" + info["file_id"] + ">下载</a></td>";
                    htmlStr += "</tr></tbody>"
                })
                $("#table").html(htmlStr);
            });
        }
    });

})